/*
 * Copyright © 2025 上海火金网络科技有限公司. All rights reserved.
 */

package cn.com.anypay.manager.miaoma.sysuserauthlog.enums;

/**
 * 认证日志相关枚举类
 */
public class AuthLogEnums {

    /**
     * 认证类型枚举
     */
    public enum AuthType {
        PASSWORD("password", "密码登录"),
        SMS("sms", "短信登录"),
        EMAIL("email", "邮箱登录"),
        WECHAT("wechat", "微信登录"),
        ALIPAY("alipay", "支付宝登录"),
        QRCODE("qrcode", "扫码登录");

        private final String code;
        private final String desc;

        AuthType(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public String getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }

        public static AuthType fromCode(String code) {
            for (AuthType type : values()) {
                if (type.code.equals(code)) {
                    return type;
                }
            }
            return null;
        }
    }

    /**
     * 操作类型枚举
     */
    public enum Operation {
        LOGIN("LOGIN", "登录"),
        LOGOUT("LOGOUT", "登出"),
        BIND("BIND", "绑定"),
        UNBIND("UNBIND", "解绑"),
        CHANGE_PASSWORD("CHANGE_PASSWORD", "修改密码"),
        RESET_PASSWORD("RESET_PASSWORD", "重置密码"),
        VERIFY_CODE("VERIFY_CODE", "验证码验证"),
        SEND_CODE("SEND_CODE", "发送验证码");

        private final String code;
        private final String desc;

        Operation(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public String getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }

        public static Operation fromCode(String code) {
            for (Operation operation : values()) {
                if (operation.code.equals(code)) {
                    return operation;
                }
            }
            return null;
        }
    }

    /**
     * 操作结果枚举
     */
    public enum Result {
        SUCCESS("SUCCESS", "成功"),
        FAILED("FAILED", "失败"),
        LOCKED("LOCKED", "锁定"),
        EXPIRED("EXPIRED", "过期"),
        INVALID("INVALID", "无效");

        private final String code;
        private final String desc;

        Result(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public String getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }

        public static Result fromCode(String code) {
            for (Result result : values()) {
                if (result.code.equals(code)) {
                    return result;
                }
            }
            return null;
        }
    }
}